/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.assets.shooterstates;

import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.templates.assets.ArmSwitchPair;
import edu.wpi.first.wpilibj.templates.assets.statemachine.State;
import edu.wpi.first.wpilibj.templates.assets.statemachine.StateMachine;
import edu.wpi.first.wpilibj.templates.commands.CommandBase;

/**
 *
 * @author Jarrod Risley
 */
public class AutonClearState extends State {

    /*
     * Global Class Variables
     */
    protected static AutonClearState CLEAR_SHOOTER =
            new AutonClearState("Spit Out Frizbees");
    
    private static double TIMEOUT_TIME = 1;
    
    private boolean switchState;
    
    public boolean switchStateOld;
    
    
    
    // CONSTRUCTOR //
    
    
    private AutonClearState(String name) {
        super(name);
    } // end RegurgitateState
    
    protected void runFirst(){
        
        System.out.println(this + " running.");
        
        setTimeoutTimer(TIMEOUT_TIME);
        
        switchState = CommandBase.shooter.checkSwitch(1);
        
        if (CommandBase.shooter.checkSwitch(1))
            CommandBase.shooter.incrementShooterCount();
        
    } // end runFirst

    
    protected void run() {
        
        CommandBase.shooter.reverseIndexer();
        switchState = CommandBase.shooter.checkSwitch(1);
        
        if (isTimedOut())
            setFinished();
        
    } // end run

    protected void runLast() {
    } // end runLast

    protected boolean isFinished() {
        return getFinished();
    } // end isFinished

    protected void end() {
        
        System.out.println(this + " ending.");
        CommandBase.shooter.stop();
        
    } // end end

    protected State getChainedInstance(State nextState) {
        
        CLEAR_SHOOTER.setNext(nextState);
        return CLEAR_SHOOTER;
        
    } // end getChainedInstance
    
} // end RegurgitateState
